﻿using Company.Core.Helpers;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.InteropServices;
using System.Text;
using System.Threading.Tasks;

namespace Company.Core.Models
{
    /// <summary>
    /// 非托管二维数组（T 为 ColorBGR/ColorBGRA）
    /// </summary>
    /// <typeparam name="T"></typeparam>
    public class UnmanagedArray2D<T> : UnmanagedArrayBase where T : struct
    {
        public int Width { get; set; }
        public int Height { get; set; }
        public UnmanagedArray2D(int width, int height, bool isResetMemory = true) : base(width * height, Marshal.SizeOf(typeof(T)), isResetMemory)
        {
            Width = width;
            Height = height;
        }

        public UnmanagedArray2D<T> DeepCopy()
        {
            var temp = new UnmanagedArray2D<T>(Width, Height);
            MemoryHelper.CopyMemory(temp.IntPtr, this.IntPtr, Size);
            return temp;
        }
    }
}
